package com.company.cloud.club.modules.db.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.company.cloud.club.modules.db.domain.ClubActivityRelative;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface ClubActivityRelativeMapper extends BaseMapper<ClubActivityRelative> {

    @Delete("DELETE FROM club_activity_relative WHERE activity_id = #{activityId, jdbcType=VARCHAR}")
    void removeByActivityId(@Param("activityId") String activityId);

    @Select("SELECT * FROM club_activity_relative WHERE activity_id = #{activityId, jdbcType=VARCHAR}")
    List<ClubActivityRelative> selectByActivityId(@Param("activityId") String activityId);

    @Select("SELECT * FROM club_activity_relative WHERE club_id = #{clubId, jdbcType=VARCHAR} " +
            "ORDER BY time_created DESC LIMIT 0, 1")
    ClubActivityRelative selectLastActivity(@Param("clubId") String clubId);

    @Select("SELECT * FROM club_activity_relative WHERE club_id = #{clubId, jdbcType=VARCHAR} " +
            "ORDER BY time_created DESC")
    List<ClubActivityRelative> selectByClubId(@Param("clubId") String clubId);

}